
<?php Yii::app()->clientScript->registerScript('employeecontact',<<<HERE
    var empno= '$employee->empno';
    Ext.onReady(function(){
        var store=Ext.create('Ext.data.Store',{
            model:'Vacationhrs',
            pageSize:20,
            autoLoad:true,
            proxy:{
                type:'ajax',
                url:'index.php?r=vacationhrs/list&empno='+empno,
                reader:{
                    type:'json',
                    root:'data',
                    totalProperty:'totalCount'
                }
            }
        })
		
		var rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
				clicksToMoveEditor: 1,
				autoCancel: false
			});
			
					// inline toolbars
		Ext.QuickTips.init();
        Ext.create('Ext.panel.Panel', {
			renderTo: 'vacation-list',
			title: 'Vacation List',
        tbar: [{
            text: 'Add',
			iconCls: 'add-icon',
			tooltip :'Add New Row',
            handler : function() {
                rowEditing.cancelEdit();
                // Create a record instance through the ModelManager
                var r = Ext.ModelManager.create({
                    hours: '1',
                    datetaken: '2011-01-01',
                    notes: 'test',
                    addedby: 'Michael Bonza',
                }, 'Vacationhrs');
                store.insert(0, r);
                rowEditing.startEdit(0, 0);
            }
        }, {
            				
			itemId: 'removeVacationhr',
            text: 'Remove',
            iconCls: 'delete-icon',
			tooltip: 'Remove Selected Row',
            handler: function() {
                var sm = grid.getSelectionModel();
                rowEditing.cancelEdit();
				alert(sm.getSelection());
				
				selectedRecords = sm.getSelection();
				myValue = selectedRecords[0].get('id');
                Ext.Ajax.request({
					method:'POST',
						url: 'index.php?r=Vacationhrs/Delete&id='+myValue,
						success: function(response, opts) {
						var obj = Ext.decode(response.responseText);
						console.dir(obj);
						},
						failure: function(response, opts) {
						console.log('server-side failure with status code ' + response.status);
						}
						});
				
				store.remove(sm.getSelection());
                sm.select(0);
            },
            disabled: false
        }]
		 });
		 	Ext.QuickTips.init();
    var grid = Ext.create('Ext.ux.LiveSearchGridPanel',{
            store:store,
            height: 450,
            width: grid_width,
            renderTo: 'vacation-list',
            viewConfig: {
                stripeRows: true
            },
			
            bbar: new Ext.PagingToolbar({
                pageSize: 20,
                store:store,
                displayInfo: true,
                displayMsg: 'Displaying topics {0} - {1} of {2}',
                emptyMsg: 'No topics to display'

            }),
            columns:[
                {
                    text:'Hours',
                    flex:1,
                    dataIndex:'hours',
					 editor: {
                // defaults to textfield if no xtype is supplied
                allowBlank: false
            }
                },
                {
                    text:'Date taken',
                    flex:1,
                    dataIndex:'datetaken',
					 editor: {
                // defaults to textfield if no xtype is supplied
                allowBlank: false
            }
                },
                {
                    text:'Notes',
                    flex:1,
                    dataIndex:'notes',
					 editor: {
                // defaults to textfield if no xtype is supplied
                allowBlank: false
            }
                },                           
                {
                    text:'Added by',
                    flex:1,
                    dataIndex:'addedby',
					 editor: {
                // defaults to textfield if no xtype is supplied
                allowBlank: false
            }
                }
            ],
			
			plugins: [rowEditing],
			
			listeners: {
					edit: function(editor,e,opt){
					alert("here");
					var	dataid = editor.record.data.id;
					var	hours = editor.record.get('hours');
					var	notes = editor.record.get('notes');
					var	datetaken = editor.record.get('datetaken');
					var	addedby = editor.record.get('addedby');
					if(dataid == ''){
					var uri = 'index.php?r=Vacationhrs/create&empno='+empno;
					}else{
					var uri = 'index.php?r=Vacationhrs/update&id='+dataid;
					}
					Ext.Ajax.request({
					method:'POST',
url: uri,
 params: { hours: hours, notes : notes,datetaken :datetaken,addedby:addedby} ,
success: function(response, opts) {
var obj = Ext.decode(response.responseText);
console.dir(obj);
},
failure: function(response, opts) {
console.log('server-side failure with status code ' + response.status);
}
});
					
					},
					'selectionchange': function(view, records) {					 
						grid.down('#removeVacationhr').setDisabled(!records.length);
					}
					}

        });
    });
HERE
        ,CClientScript::POS_BEGIN);?>


<div id="left-col">
    <?php  $this->renderPartial('_side',array(
        'employee'=>$employee
    ));?>
</div>

<div id="right-col">

    <div class="wrap">
        <div class="container">

            
            <div id="breadcrumb" style="display:none;"><span style="padding-left:10px;font-size:10px;color:#777777;" id="alsoviewing"></span></div>
            <div class="inside">
                <?php $this->renderPartial('/employees/_view',array(
                    'model'=>$employee,
                ));?>
              
               
                <?php $this->renderPartial('/employees/_tab',array(
                    'model'=>$employee,
                ));?>
                 <br/>
                 
                
                <div id="vacation-list"></div>


                
            </div><!-- inside -->
        </div><!-- container -->
    </div><!-- wrap -->
    <?php $this->renderPartial('/copyright'); ?>
</div> <!-- left-col -->